//
//  ControllerLayer.h
//  NinjaTurtle
//
//  Created by Nguyen Tri Chung on 1/30/15.
//
//

#ifndef __NinjaTurtle__ControllerLayer__
#define __NinjaTurtle__ControllerLayer__

#include <stdio.h>
#include "cocos2d.h"
#include "../model/model.h"
#include "../support/support.h"

USING_NS_CC;

class ControllerLayer : public Layer {
    CC_SYNTHESIZE(CSprite*, buttonC, ButtonC);
protected:
    View* gameScene;
    char* keyMap;
    CSprite* buttonLeft;
    CSprite* buttonRight;
    CSprite* buttonA;
    CSprite* buttonB;
    Map<Touch*, __Integer*>* savedTouches;
private:
    EventListenerTouchAllAtOnce* touchListener;
    
    void initialize();
    void createLayers();
    void createLayersContent();
    
    void onTouchesBegan(const std::vector<Touch*>& touches, Event* event);
    void onTouchesMoved(const std::vector<Touch*>& touches, Event* event);
    void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
    void onTouchesCancelled(const std::vector<Touch*>& touches, Event* event);
    
    void checkTouchComeIn(const std::vector<Touch*>& touches);
    void checkTouchComeOut(const std::vector<Touch*>& touches);
    void checkTouchComeOutAndRelease(const std::vector<Touch*>& touches);
public:
    ControllerLayer(View* gameScene);
    virtual ~ControllerLayer();
    void update(float dt);
};

#endif /* defined(__NinjaTurtle__ControllerLayer__) */
